{extend name='admin@public/content'}

{block name="content"}
<form onsubmit="return false;" action="{:request()->url()}" data-auto="true" method="post" id="ProductForm"
			class='form-horizontal layui-form padding-top-20'>


	<!--{if !empty($cates)}-->
	<div class="form-group">
		<label class="col-sm-2 control-label">分类</label>
		<div class='col-sm-8 text-top'>
			<select required class="layui-select full-width" name="cate_id">
				{foreach $cates as $cate}
				<!--{if isset($vo.cate_id) and $cate.id eq $vo.cate_id}-->
				<option selected value="{$cate.id}">{$cate.spl|raw}{$cate.cate_title}</option>
				<!--{else}-->
				<option value="{$cate.id}">{$cate.spl|raw}{$cate.cate_title}</option>
				<!--{/if}-->
				{/foreach}
			</select>
		</div>
	</div>
	<!--{/if}-->

	<div class="form-group">
		<label class="col-sm-2 control-label">名称</label>
		<div class='col-sm-8'>
			<input name="title" required value="{$vo.title|default=''}" class="layui-input" title="请输入名称"
						 placeholder="请输入名称">
		</div>
	</div>


	<div class="form-group">
		<label class="col-sm-2 control-label label-required">图片</label>
		<div class='col-sm-8'>
			<table class="layui-table background-item margin-none" lay-size="sm" lay-skin="nob">
				<thead>
				<tr>
					<td>缩略图</td>
				</tr>
				</thead>
				<tbody>
				<tr>
					<td class="text-top" style="width:100px">
						<input type="hidden" name="cover" value="{$vo.cover|default=''}">
					</td>
				</tr>
				</tbody>
			</table>
		</div>
	</div>


	<div class="form-group">
		<label class="col-sm-2 control-label label-required">详情</label>
		<div class='col-sm-8'>
			<textarea name="content">{$vo.content|default=''|htmlspecialchars_decode}</textarea>
		</div>
	</div>

	<div class="hr-line-dashed"></div>

	<div class="col-sm-7 col-sm-offset-2">
		<div class="layui-form-item text-center">
			{if !empty($vo.id)}
			<input type="hidden" name="id" value="{$vo.id}"/>
			{else /}
			<input type="hidden" name="create_at" value="{:time()}"/>
			{/if}
			<input type="hidden" name="status" value="{$vo.status|default=1}"/>
			<button class="layui-btn" type="submit">保存</button>
			<button class="layui-btn layui-btn-danger" type='button' onclick="window.history.back()">取消编辑</button>
		</div>
	</div>

</form>

<script>
	require(['jquery', 'ckeditor', 'angular'], function () {
		window.form.render();
		window.createEditor('[name="content"]', {height: 500});
		var app = angular.module("ProductForm", []).run(callback);
		angular.bootstrap(document.getElementById(app.name), [app.name]);

		function callback($rootScope) {
			// 单图片上传处理
			$('#ProductForm [name="cover"]').uploadOneImage();
			// 多图片上传处理
			//$('#ProductForm [name="goods_image"]').uploadMultipleImage();
		}
	});
</script>
{/block}

{block name="style"}
<style>

	.background-item {
		padding: 15px;
		background: #efefef;
	}

	.background-item thead tr {
		background: #e0e0e0
	}

	.price-input-td {
		padding: 0 !important;
	}

	.price-input-td:before {
		margin: 4px;
		width: 35px;
		height: 22px;
		content: "金额";
		line-height: 20px;
		text-align: center;
		position: absolute;
		background: #e2e2e2;
	}

	.price-input-td input {
		height: 30px;
		padding-left: 50px;
		border: none !important;
	}
</style>
{/block}